/*
 * @author: Lzg
 */
// wifi配置
var PageWifi = {
    id: "PageWifi", //页面id
    menu: "i18n.lan.menu.dataTrans", //所属菜单(一级菜单名)
    title: "i18n.lan.menu.PageWifi", //标题（二级菜单名）
    icon: "icon-me-gprs", //图标
    refreshBtnCmd: "DUMP_CORE", //刷新按钮指令
    saveBtn: true, //保存按钮
    content: "test", //页面内容
    el: [ //控件  
        { //css定义
            elname: "style",
            text: "#PageWifi > label{min-width:80px;}",
        },
        { //静态ip
            elname: "text",
            label: i18n.lan.PageWifi.staticIp,
            attrs: {
                dumpKey: "WIFI_IP",
                dumpParamIndex: 0,
                cmdKey: "WIFIIP",
                getValue: "PageWifi_getWifiIp()",
                id: "PageWifi_staticIp"
            },
            endRow: true,
        },
        { //网关
            elname: "text",
            label: i18n.lan.PageWifi.gateway,
            attrs: {
                dumpKey: "WIFI_IP",
                dumpParamIndex: 1,
                id: "PageWifi_gateway"
            },
            endRow: true,
        },
        { //子网掩码
            elname: "text",
            label: i18n.lan.PageWifi.netmask,
            attrs: {
                dumpKey: "WIFI_IP",
                dumpParamIndex: 2,
                id: "PageWifi_netmask"
            },
            endRow: true,
        },
        { //状态
            elname: "text",
            label: i18n.lan.PageWifi.state,
            attrs: {
                dumpKey: "WIFI_STATE",
            },
            endRow: true,
        },
        {
            elname: "datagrid",
            rowCount: Device.getNodesCount("wifi"),
            data: {
                width: "460px",
                columns: [
                    [ //表格列,field为列标题
                        {
                            field: "index",
                            width: 40,
                            align: "center",
                        },
                        { //用户名
                            field: "ssid",
                            editor: Easyui.editor.textbox,
                            dumpKey: "WIFIAP<n>",//最好要求改下刷新指令为WIFIAP<n> user,password
                            dumpParamIndex: 0,
                            cmdKey: "WIFIAP<n>,",
                            getValue: "PageWifi_getWifiAp(rows[row].index)",
                            width: 200,
                        },
                        { //密码
                            field: "password",
                            editor: Easyui.editor.textbox,
                            dumpKey: "WIFIAP<n>",
                            dumpParamIndex: 1,
                            width: 200,
                        },
                    ]
                ],
            }
        },
    ],
}
CmdPage.add(PageWifi); //添加到页面管理

//获得wifi参数
function PageWifi_getWifiAp(row){
    let ssid = PageWifi.dgData.rows[row].ssid;
    let password = PageWifi.dgData.rows[row].password;
    return ssid + "," + password;
}

//获得wifi ip参数
function PageWifi_getWifiIp() {
    let wifiIp = $('#PageWifi_staticIp').val();
    let gateway = $('#PageWifi_gateway').val();
    let netmask = $('#PageWifi_netmask').val();
    return wifiIp + "," + gateway + "," + netmask;
}
